package com.hand.hap.demo.workflow;

import com.hand.hap.activiti.custom.IActivitiBean;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Component;

/**
 * @author shuai.wang02@hand-china.com
 * @version 1.0
 * @description
 * @date 2018/8/7 14:57
 */
@Component
public class CreditService implements JavaDelegate, IActivitiBean {
    @Override
    public void execute(DelegateExecution execution) {
        Integer amount = execution.getVariable("amount",Integer.class);
        Integer credit = execution.getVariable("credit",Integer.class);

        if (amount>credit){
            execution.setVariable("accept",Boolean.FALSE);
        }else {
            execution.setVariable("accept",Boolean.TRUE);
        }
    }

    @Override
    public String getBeanName() {
        return "checkCredit";
    }
}
